import java.util.Scanner;

public class test2 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入:");
        int num=scanner.nextInt();
        int [][] arr=new int[num][num];
        int le=arr.length % 2==0 ? arr.length/2:arr.length/2+1;
        int count=1, left=0,re=arr.length-1,top=0,botten=arr.length-1;

        for (int i = 0; i < le ; i++) {
            for (int j = left; j <=re ; j++) {
                arr[top][j]=count;

                count++;
            }
            top++ ;

            for (int j = top; j <=botten ; j++) {
                arr[j][re]=count;
                count++;
            }
          re--;
            for (int j = re; j >=left ; j--) {
                arr[botten][j]=count;
                count++;
            }
            botten--;
            for (int j = botten; j >=top ; j--) {
                arr[j][left]=count;
                count++;
            }
            left++;
        }

        for (int i = 0; i <arr.length ; i++) {
            for (int j = 0; j <arr.length ; j++) {
                System.out.print(arr[i][j]+"\t");
            }
            System.out.println();
        }
    }


}
